package friendApi

import (
	"chart.zozoo.net/app/service/friendService"
	"chart.zozoo.net/app/utils/rsp"
	"github.com/gin-gonic/gin"
)

// Search 搜索好友
func Search(c *gin.Context) {
	uuid := c.GetString("uuid")
	keywords := c.Query("keywords")
	if len(keywords) == 0 {
		rsp.JsonErr(c, rsp.SetMsg("请传入用户微信号或手机号"))
		return
	}

	u, err := friendService.Search(uuid, keywords)
	if err != nil {
		rsp.JsonErr(c, rsp.SetMsg(err.Error()))
		return
	}

	rsp.JsonOk(c, rsp.SetData(u))
}
